/*
 * @Descripttion: 招商经理管理
 * @version:
 * @Author: lehaixia
 * @Date: 2023-04-18 10:40:59
 * @LastEditors: lehaixia
 * @LastEditTime: 2023-05-23 15:50:54
 */
import request from '@/plugins/request'
import { IResponseData } from '@/types/request-base'
import { json2FormData } from '@/utils'

/**
 * 招商经理查询
 * @param {object} data 参数
 */
export function getManagetList({ page, rows, sort, order, filtersRaw, sortersRaw, paramsRaw }: any) {
  const params = {
    page,
    rows,
    sort: sort || 'lastUpdateTime',
    order: order || 'desc',
    pageFlag: true,
    onlyCountFlag: false,
    filtersRaw: JSON.stringify(filtersRaw),
    sortersRaw: JSON.stringify(sortersRaw),
    paramsRaw: JSON.stringify(paramsRaw)
  }
  const data = json2FormData(params)
  return request<IResponseData>({
    url: '/app/v1/ctmInvestmentManager/page',
    method: 'post',
    data
  })
}

/**
 *  新增/编辑
 * @param data any
 * @returns
 */
export function save(data: any) {
  return request<IResponseData>({
    url: '/app/v1/ctmInvestmentManager',
    method: data.id ? 'put' : 'post',
    data
  })
}

/**
 * 详情 根据ID查询
 * @param {string} ID
 */
export function detail(id: string) {
  return request<IResponseData>({
    method: 'get',
    url: `/app/v1/ctmInvestmentManager/${id}`,
    loading: true
  })
}

/**
 * 启用/停用
 * @param {array} data
 * @param {string} url
 */
export function enableOrDisable(data: any, type: string) {
  return request<IResponseData>({
    method: 'put',
    url: `/app/v1/ctmInvestmentManager/${type}`,
    data
  })
}

/**
 * 分页查询 查qup平台招商经理
 * @param {object} data 参数
 */
export function getLeasingMgtList({ page, rows, sort, order, filtersRaw, sortersRaw, paramsRaw }: any) {
  const params = {
    page,
    rows,
    sort: sort || '',
    order: order || 'DESC',
    pageFlag: true,
    onlyCountFlag: false,
    filtersRaw: JSON.stringify(filtersRaw),
    sortersRaw: JSON.stringify(sortersRaw),
    paramsRaw: JSON.stringify(paramsRaw)
  }
  const data = json2FormData(params)
  return request<IResponseData>({
    method: 'post',
    url: `/app/v1/ctmInvestmentManager/domainUser/page`,
    data
  })
}
